package com.xxx.corejava.day1125;

public class IntStack {
    private int[] data;
    private int size;

    public IntStack(int max) {
        data=new int[max];
        size=0;
    }

    public IntStack() {
        //只能出现在构造方法的第一行
        this(10);
    }


    public boolean isFull(){
        return size==data.length;
    }

    public boolean isEmpty(){
        return size==0;
    }

    public void push(int i){

        if(isFull()){
            throw new RuntimeException("栈已满");
        }

        data[size++]=i;
    }

    public int pop(){

        if(isEmpty()){
            throw new RuntimeException("栈已空");
        }

        return data[--size];
    }


    public int getSize() {
        return size;
    }
}
